package com.zbkj.common.enums;

/**
 * 方法类型枚举
 *  +----------------------------------------------------------------------
 *  | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
 *  +----------------------------------------------------------------------
 *  | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
 *  +----------------------------------------------------------------------
 *  | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
 *  +----------------------------------------------------------------------
 *  | Author: CRMEB Team <admin@crmeb.com>
 *  +----------------------------------------------------------------------
 */
public enum UserType {

    AllUser(0, "所有用户"),
    NewUser(1, "新用户"),
    OldUser(2, "老用户");

    private final Integer code;
    private final String name;

    UserType(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static String getName(Integer code){
        for (UserType modelType : UserType.values()) {
            if (modelType.getCode().equals(code))
                return modelType.getName();
        }
        return null;
    }

    public static Integer getCode(String name){
        for (UserType modelType : UserType.values()) {
            if (modelType.getName().equals(name))
                return modelType.getCode();
        }
        return 0;
    }
}
